/////////////////////////////////////////////////////////////////////////////
// Name:        ax_supportedfiles.h
// Purpose:     A class for manipulating supported file types
// Author:      Julian Smart
// Modified by:
// Created:     2008-11-18
// RCS-ID:      $Id$
// Copyright:   (c) Julian Smart
// Licence:     New BSD License
/////////////////////////////////////////////////////////////////////////////

#ifndef _AX_SUPPORTEDFILES_H_
#define _AX_SUPPORTEDFILES_H_

class wxConfigBase;
class wxCheckListBox;

/**
    @class AxSupportedFiles
    
    A class for manipulating supported file types.

    @category{ax_resource}
 */

class AxSupportedFiles: public wxObject
{
public:
    AxSupportedFiles() {}
    AxSupportedFiles(const AxSupportedFiles& supported) { Copy(supported); }
    ~AxSupportedFiles() {}

//// Operations

    void operator = (const AxSupportedFiles& supported) { Copy(supported); }
    void Copy (const AxSupportedFiles& supported);

    /// Load config info
    bool LoadConfig(wxConfigBase& config);

    /// Save config info
    bool SaveConfig(wxConfigBase& config);

    /// Do some initialisation
    void Init();

    /// Clear arrays
    void Clear();

    /// Add a supported file type
    bool AddFileType(const wxString& ext, const wxString& description, bool enabled = true);

    /// Enable file type
    bool Enable(const wxString& ext, bool enabled = true);

    /// Is this type enabled?
    bool IsEnabled(const wxString& ext) const;

    /// Does this type exist?
    bool TypeExists(const wxString& ext) const;

    /// Get number of extensions
    size_t GetCount() const { return m_supportedFileExtensions.GetCount(); }

    /// Get extension
    wxString GetExtension(int idx) const { return m_supportedFileExtensions[idx]; }

    /// Get description
    wxString GetDescription(int idx) const { return m_supportedFileDescriptions[idx]; }

    /// Get enabled state
    bool GetEnabled(int idx) const { return m_supportedFileStates[idx] != 0; }

    /// Remove file type
    bool RemoveFileType(int idx);

    /// Get arrays
    wxArrayString& GetFileExtensions() { return m_supportedFileExtensions; }
    wxArrayString& GetFileDescriptions() { return m_supportedFileDescriptions; }
    wxArrayInt& GetFileStates() { return m_supportedFileStates; }

    /// Transfer enabled states to and from checklistbox
    bool TransferDataToCheckListBox(wxCheckListBox* checkListBox, bool recreateList = true);
    bool TransferDataFromCheckListBox(wxCheckListBox* checkListBox);

    /// Get a wildcard with all enabled extensions
    wxString GetWildcard() const;

protected:
    wxArrayString   m_supportedFileExtensions;
    wxArrayString   m_supportedFileDescriptions;
    wxArrayInt      m_supportedFileStates;
};

#endif
    // _AX_SUPPORTEDFILES_H_
